package logic

import (
	"context"

	"mail/service/receipt/api/internal/svc"
	"mail/service/receipt/api/internal/types"
	"mail/service/receipt/rpc/receiptclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type RevampLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRevampLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RevampLogic {
	return &RevampLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RevampLogic) Revamp(req *types.RevampRequest) (resp *types.RevampResponse, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.ReceiptRpc.Revamp(l.ctx, &receiptclient.RevampRequest{
		Id:     req.Id,
		Uid:    req.Uid,
		Pid:    req.Pid,
		Amount: req.Amount,
		Status: req.Status,
	})
	if err != nil {
		return nil, err
	}

	return &types.RevampResponse{}, nil
}
